home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #2
/
Amiga Plus CD - 2004 - No. 02.iso
/
AmigaPlus
/
Tools
/
Development
/
AmigaTalk
/
user
/
SqMatrix.st
< prev
next >
Wrap
Text File
|
2004-01-31
|
1KB
|
49 lines
" -------------------------------------------------------------- "
" SqMatrix.st - Implementation of Square Matrices for AmigaTalk. "
" -------------------------------------------------------------- "
Class SqMatrix :Magnitude ! size ele !
[
new: newSize
(newSize < 2)
ifTrue: [ ('size of SqMatrix too small!') print.
^ nil
].
size <- newSize.
ele <- Array new: (size * size).
(1 to: (size * size)) do: [:i | ele at: i put: (Float new: 0.0)].
^ self
|
scale: s
(1 to: (size * size)) do: [:i | ele at: i put: (s * (ele at: i))].
^ self
|
getElementAt: rcPoint ! idx !
((rcPoint x) < 1 | (rcPoint y) < 1)
ifTrue: [ ('Row@Column below minimum(1) in SqMatrix.') print.
^ nil
].
idx <- (size * ((rcPoint x) - 1) + rcPoint y).
^ ele at: idx
|
setElement: val at: rcPoint ! idx !
((rcPoint x) < 1 | (rcPoint y) < 1)
ifTrue: [ ('Row@Column below minimum(1) in SqMatrix.') print.
^ nil
].
((rcPoint x) > size | (rcPoint y) > size)
ifTrue: [ ('Row@Column > size in SqMatrix.') print.
^ nil
].
idx <- (size * ((rcPoint x) - 1) + rcPoint y).
ele at: idx put: val.
^ self
]